<?php
/*
 * @Author: lokei
 * @Date: 2023-01-14 19:44:26
 * @LastEditors: lokei
 * @LastEditTime: 2023-01-14 20:01:55
 * @Description: 
 */
namespace App\Http\Controllers\Chuxing;

use App\Common\Tools\ResultTool;
use App\Http\Controllers\Controller;
use App\Models\Chuxing\LineModel;
use Illuminate\Http\Request;

class LineController extends Controller {
    public function list() {
        $items = LineModel::get();
        $res = ResultTool::success();
        $res['data']['items'] = $items;
        $res['data']['total'] = count($items);
        return $res;
    }

    public function delete(Request $request) {
        LineModel::where('id', '=', $request->input('id'))->delete();
        return ResultTool::success();
    }

    public function create(Request $request) {
        $line = new LineModel();
        $line->departure_city = $request->input('departure_city');
        $line->terminal_city = $request->input('terminal_city');
        $line->save();
        return ResultTool::success();
    }
}